<?php
/**
* presenter interface
*/
class PresenterInterface
{

	public static function query($condition) {
		
		return PresenterTrail::model()->with('song')->findAllByAttributes(
			$condition,
			array('order'=>'date_update desc')
		);
	}
	
	public static function create($refid,$userid) {
		
		if ( self::status($refid) ) {
			
			$presenterTrail = new PresenterTrail('create');
			$presenterTrail->attributes = array(
				'song_id'	=>$refid,
				'user_id'		=>$userid,
				'date_create'	=>date('Y-m-d H:i:s'),
			);
			$presenterTrail->save();
			
			# successfully borrow, success
			return true;
		} else {
			# borrowed by other, failed
			return false;
		}
	}
	
}

?>